package com.yuanfeng.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanfeng.commoms.vo.goods.GoodsDetailsListVO;
import com.yuanfeng.order.dto.ApplyReturnGoodDTO;
import com.yuanfeng.order.dto.OrderGoodsDiscountDTO;
import com.yuanfeng.order.entity.OrderGoodsEntity;
import com.yuanfeng.order.vo.GoodsDetailsVO;
import com.yuanfeng.order.vo.GoodsParaVO;
import com.yuanfeng.order.vo.ShipmentsByOrderGoodsDetailsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ClassName OrderGoodsMapper
 * @Description 订单商品表
 * @Author cyp
 * @Date 2023-05-31 11:41:48
 * @Version 1.0
 **/
@Mapper
public interface OrderGoodsMapper extends BaseMapper<OrderGoodsEntity> {


    /**
     * 查询商品数量
     * @param param
     * @return
     */
    Integer queryOrderGoodsCount(@Param("param") Map<String, Object> param);

    /**
     *查询门店商品数量
     * @param commonId
     * @param shopId
     * @return
     */
    Integer queryShopTakeGoodsStart(@Param("commonId") Integer commonId, @Param("shopId") String shopId);

    /**
     * 查询分类抽佣比例
     *
     * @param catId
     * @return
     */
    BigDecimal queryCatCommission(@Param("catId")Integer catId);

    /**
     * 新增订单商品
     * @param totalGoodsShippingFee
     * @param orderId
     * @param shopId
     * @param shopName
     * @param goodsId
     * @param commonId
     * @param userId
     * @param goodsName
     * @param catId
     * @param goodsSpec
     * @param goodsprice
     * @param goodsNumber
     * @param goodsImage
     * @param goodsShippingFee
     * @param orderGoodsAmount
     * @param orderGoodsPlatformBear
     * @param paymentRealPrice
     * @param orderGoodsStatus
     * @param orderGoodsEvaluationStatus
     * @param goodsRtpPrice
     * @param couponSumMoney
     * @param platformVoucherRptPrice
     * @param goodsReturnStatus
     * @param goodsRefundStatus
     * @param orderGoodsTime
     * @param orderGoodsIdDeliver
     * @param promotionId
     * @param smallOrder
     * @param integral
     * @param dealerCommission
     * @param supplyCommission
     * @param orderGoodsCommission
     * @param goodsMemberDiscount
     * @param orderDiscountFee
     * @param plusgoodsprice
     * @param goodsPlusDis
     * @return
     */
    boolean insertByOrderGoods(@Param("totalGoodsShippingFee") BigDecimal totalGoodsShippingFee,@Param("orderId") String orderId, @Param("shopId") Integer shopId,
                               @Param("shopName") String shopName, @Param("goodsId") Integer goodsId, @Param("commonId") Integer commonId,
                               @Param("userId") String userId, @Param("goodsName") String goodsName, @Param("catId") Integer catId,
                               @Param("goodsSpec") String goodsSpec, @Param("goodsprice") BigDecimal goodsprice,
                               @Param("goodsNumber") Integer goodsNumber, @Param("goodsImage") String goodsImage,
                               @Param("goodsShippingFee") BigDecimal goodsShippingFee,
                               @Param("orderGoodsAmount") BigDecimal orderGoodsAmount,
                               @Param("orderGoodsPlatformBear") BigDecimal orderGoodsPlatformBear,
                               @Param("paymentRealPrice") BigDecimal paymentRealPrice, @Param("orderGoodsStatus") Integer orderGoodsStatus,
                               @Param("orderGoodsEvaluationStatus") Integer orderGoodsEvaluationStatus,
                               @Param("goodsRtpPrice") BigDecimal goodsRtpPrice, @Param("couponSumMoney") BigDecimal couponSumMoney,@Param("platformVoucherRptPrice") BigDecimal platformVoucherRptPrice,
                               @Param("goodsReturnStatus") Integer goodsReturnStatus,
                               @Param("goodsRefundStatus") Integer goodsRefundStatus, @Param("orderGoodsTime") String orderGoodsTime,
                               @Param("orderGoodsIdDeliver") Integer orderGoodsIdDeliver,@Param("promotionId") Integer promotionId,@Param("smallOrder") Integer smallOrder,
                               @Param("integral") Integer integral,@Param("dealerCommission") BigDecimal dealerCommission, @Param("supplyCommission") BigDecimal supplyCommission,
                               @Param("orderGoodsCommission") BigDecimal orderGoodsCommission,@Param("goodsMemberDiscount")BigDecimal goodsMemberDiscount ,
                               @Param("orderDiscountFee") BigDecimal orderDiscountFee,@Param("plusgoodsprice") BigDecimal plusgoodsprice,@Param("goodsPlusDis") Integer goodsPlusDis,
                               @Param("fullReductionDiscount") BigDecimal fullReductionDiscount,@Param("fullFoldingDiscount") BigDecimal fullFoldingDiscount,
                               @Param("activityUnitPrice") BigDecimal activityUnitPrice,@Param("goodsPromotionId") Integer goodsPromotionId,@Param("voucherId") Integer voucherId);

    /**
     * 获取信息
     *
     * @param orderId
     * @return
     */
    Map<Object, Object> getVitualInfo(@Param("orderId") String orderId);

    /**
     * 查询采购编号
     *
     * @param orderId
     * @param goodsId
     * @return
     */
    Integer queryBuyNumByorderId1(@Param("orderId") String orderId, @Param("goodsId") Integer goodsId);

    /**
     * 查询商品集合
     *
     * @param orderId
     * @return
     */
    List<GoodsDetailsListVO> queryGoodsList(@Param("orderId") String orderId);

    /**
     * 更改状态
     */
   boolean updateOrderGoodsByStatusByPureDigital(@Param("orderStatus") Integer orderStatus,@Param("paymentNumbers") String paymentNumbers);

    /**
     * 更新商品状态
     */
   boolean updateOrderGoodsByStatus(@Param("orderStatus") Integer orderStatus,@Param("orderNumber") String orderNumber);

    /**
     * 商品集合详情
     *
     * @param orderId
     * @return
     */
    List<GoodsDetailsVO> listGoodsDetails(@Param("orderId") String orderId);

    /**
     * 退还商品集合
     *
     * @param paraMap
     * @return
     */
    List<GoodsDetailsVO> listReturnGoods(@Param("paraMap") Map<String, String> paraMap);

    /**
     * 退款商品集合
     *
     * @param selectMap
     * @return
     */
    List<GoodsDetailsVO> listReturnGoods1(Map<String, String> selectMap);


    /**
     * 获取发货人代码
     *
     * @param shippingCode
     * @param orderId
     * @return
     */
    Map<Object, Object> getShipperCode2(@Param("shippingCode") String shippingCode, @Param("orderId") String orderId);


    /**
     * 查询订单商品信息
     * @param page
     * @param paraMap
     * @return
     */
    IPage<GoodsDetailsListVO> queryGoodsList2(IPage<GoodsDetailsListVO> page , @Param("param") Map<String, Object> paraMap);

    /**
     * 查询商品集合
     *
     * @param orderId
     * @return
     */
    List<GoodsDetailsListVO> queryGoodsList1(String orderId);


    /**
     * 查询店铺订单商品列表
     * @param page
     * @param param
     * @return
     */
    IPage<GoodsDetailsListVO> queryGoodsListByPage(IPage<GoodsDetailsListVO> page , @Param("param") Map<String, Object> param);


    /**
     * 查询订单采购数量
     *
     * @param orderId
     * @param orderGoodsId
     * @return
     */
    ApplyReturnGoodDTO queryOrderPurchaseQuantity(String orderId, String orderGoodsId);


    /**
     * 获取商品折扣
     *
     * @param getGoodsMap
     * @return
     */
    OrderGoodsDiscountDTO getGoodsDiscount(Map<String, String> getGoodsMap);


    /**
     * 查询商品全部排行
     *
     * @return
     */
    List<GoodsParaVO> queryAllGoods();

    /**
     * 查询商品本日排行
     *
     * @return
     */
    List<GoodsParaVO> queryTodayGoods();

    /**
     * 查询商品本周排行
     *
     * @return
     */
    List<GoodsParaVO> queryWeekGoods();

    /**
     * 查询商品本月排行
     *
     * @return
     */
    List<GoodsParaVO> queryMonthGoods();

    /**
     * 查询商品本年排行
     *
     * @return
     */
    List<GoodsParaVO> queryYearGoods();

    /**
     * 添加供应商订单
     * @param orderId
     * @param shopId
     * @param shopName
     * @param goodsId
     * @param commonId
     * @param userId
     * @param goodsName
     * @param catId
     * @param goodsSpec
     * @param goodsprice
     * @param goodsNumber
     * @param goodsImage
     * @param goodsShippingFee
     * @param orderGoodsAmount
     * @param orderGoodsPlatformBear
     * @param paymentRealPrice
     * @param orderGoodsStatus
     * @param orderGoodsEvaluationStatus
     * @param goodsRtpPrice
     * @param couponSumMoney
     * @param platformVoucherRptPrice
     * @param goodsReturnStatus
     * @param goodsRefundStatus
     * @param orderGoodsTime
     * @param orderGoodsIdDeliver
     * @param promotionId
     * @param smallOrder
     * @param integral
     * @param dealerCommission
     * @param supplyCommission
     * @param orderGoodsCommission
     * @param goodsMemberDiscount
     */
    void insertSupplierByOrderGoods(@Param("orderId") String orderId, @Param("shopId") Integer shopId,
                                    @Param("shopName") String shopName, @Param("goodsId") Integer goodsId, @Param("commonId") Integer commonId,
                                    @Param("userId") String userId, @Param("goodsName") String goodsName, @Param("catId") Integer catId,
                                    @Param("goodsSpec") String goodsSpec, @Param("goodsprice") BigDecimal goodsprice,
                                    @Param("goodsNumber") Integer goodsNumber, @Param("goodsImage") String goodsImage,
                                    @Param("goodsShippingFee") BigDecimal goodsShippingFee,
                                    @Param("orderGoodsAmount") BigDecimal orderGoodsAmount,
                                    @Param("orderGoodsPlatformBear") BigDecimal orderGoodsPlatformBear,
                                    @Param("paymentRealPrice") BigDecimal paymentRealPrice, @Param("orderGoodsStatus") Integer orderGoodsStatus,
                                    @Param("orderGoodsEvaluationStatus") Integer orderGoodsEvaluationStatus,
                                    @Param("goodsRtpPrice") BigDecimal goodsRtpPrice, @Param("couponSumMoney") BigDecimal couponSumMoney,@Param("platformVoucherRptPrice") BigDecimal platformVoucherRptPrice,
                                    @Param("goodsReturnStatus") Integer goodsReturnStatus,
                                    @Param("goodsRefundStatus") Integer goodsRefundStatus, @Param("orderGoodsTime") String orderGoodsTime,
                                    @Param("orderGoodsIdDeliver") Integer orderGoodsIdDeliver,@Param("promotionId") Integer promotionId,@Param("smallOrder") Integer smallOrder,@Param("integral") Integer integral,
                                    @Param("dealerCommission") BigDecimal dealerCommission, @Param("supplyCommission") BigDecimal supplyCommission,@Param("orderGoodsCommission")BigDecimal orderGoodsCommission,@Param("goodsMemberDiscount")BigDecimal goodsMemberDiscount);


    /**
     * 批量发货
     *
     * @param mapGoods
     * @return
     */
    boolean piLiangupdateByOrderGoods(Map<String, Object> mapGoods);

    /**
     * 发货
     *
     * @param mapGoods
     * @return
     */
    boolean updateByOrderGoods(Map<String, Object> mapGoods);

    /**
     * 供应商  待发货订单
     * @param orderId
     * @return
     */
    List<ShipmentsByOrderGoodsDetailsVO> ShipmentsByOrderGoods(@Param("orderId")String orderId);

    /**
     * 供应商 已售经销，已售自销订单
     * @param orderId
     * @return
     */
    List<GoodsDetailsVO> querySupplyOrders(@Param("orderId")String orderId);


    /**
     * 分开发货
     *
     * @param mapGoods
     * @return
     */
    boolean updateSeparateShipmentsByOrderGoods(Map<String, Object> mapGoods);


    /**
     * 按订单货物发货
     *
     * @param orderId
     * @return
     */
    List<ShipmentsByOrderGoodsDetailsVO> shipmentsByOrderGoods(String orderId);


    /**
     * 查询订单
     *
     * @param orderId
     * @return
     */
    List<GoodsDetailsVO> queryOrders(String orderId);

    /**
     * 查询商品集合
     *
     * @param orderId
     * @return
     */
    List<GoodsDetailsListVO> queryGoodsListLimit(@Param("orderId") String orderId);

    /**
     * 查询订单商品信息
     * @param map
     * @return
     */
    List<GoodsDetailsListVO> queryComplaintsByGoodsList(@Param("param")Map<String, Object> map);

    /**
     * 商品实付金额
     * @param goodsId
     * @param orderId
     * @return
     */
    BigDecimal selectgoodsprice(@Param("goodsId")Integer goodsId,@Param("orderId")String orderId);

    /**
     * 如果订单包含赠品 查询
     * @param orderId
     * @return
     */
    String queryOrderZengpinInfo(@Param("param")String orderId);

    /**
     * 查询当前订单是否改价
     * @param map
     * @return
     */
    Integer queryOrderUpdatePrice(@Param("param")Map<String, Object> map);


    /**
     * 更新订单商品
     *
     * @param updateGoodsMap
     */
    void updateOrderGoodsById2(Map<String, Object> updateGoodsMap);

    Integer queryBuyCountByGoodsId(@Param("goodsId") Integer goodsId,@Param("userId") String userId);

    Integer queryOrderGoodsCountByDiscount(@Param("param") Map<String, Object> param);

    BigDecimal selectPayGoods(@Param("orderId") String orderId,@Param("returnGoods") List<Integer> returnGoods);

    BigDecimal selectFeeGoods(@Param("orderId") String orderId,@Param("returnGoods") List<Integer> returnGoods);
}
